package com.coolwen.service;

import com.coolwen.dao.UserMapper;
import com.coolwen.entity.User;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by user on 2016-11-10.
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    //引入log4j,进行日志打印
    private static final Logger LOGGER = Logger.getLogger(UserServiceImpl.class);


    @Override
    public User findByUserId(Integer uId) {
        return userMapper.selectByPrimaryKey(uId);
    }

    @Override
    public List<User> findAllUsers() {
        return null;
    }

    @Override
    public int deleteUserByRequest(int requestType, String requestValue) {
        return 0;
    }

    @Override
    public int updateUserByUserId(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public User findBelongGroups(Integer userId) {
        return userMapper.selectBelongGroupsByUserId(userId);
    }

    @Override
    public List<User> findByGroupId(Integer groupId) {
        return userMapper.selectByGroupId(groupId);
    }

    @Override
    public User findByUserOpenIdAndUserPassword(String userOpenId, String userPassword) {
        return userMapper.selectByUserOpenIdAndUserPassword(userOpenId,userPassword);
    }
}
